Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git] / 575 - Skew Binary / 575.cpp
blobfe326bcea84631e480636e6c464850b304d21d83
1 #include <stdio.h>
2 #include <math.h>
3 #include <iostream>
5 //#define DEBUGUEANDO
7 using namespace std;
9 int main()
11 int n[32];
12 int sizeN; //Numero de digitos de N
13 unsigned int d; //equivalente decimal de n
14 while (cin.peek() != EOF){
15 //Leer linea
16 sizeN = 0;
17 while(cin.peek() != '\n'){
18 n[sizeN] = cin.get() - 48;
19 #ifdef DEBUGUEANDO
20 cout << "Lei: " << n[sizeN] << " Size es: " << sizeN << endl;
21 #endif
22 sizeN++;
24 if (sizeN == 1 && n[0] == 0)
25 break;
26 #ifdef DEBUGUEANDO
27 for (int i = 0; i < sizeN; i++)
28 cout << n[i];
29 cout << endl << "Size is: " << sizeN << endl;
30 #endif
31 //Procesar caso aquĆ­
32 d = 0;
33 for (int i = 0; i<sizeN; i++){
34 d += n[i] * ((int)pow(2, (sizeN - i)) - 1);
36 cout << d << endl;
37 cin.get();
39 return 0;